<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="执行标准" name="first"><zxbz v-if="activeName=='first'" /></el-tab-pane>
      <el-tab-pane label="安全类别" name="second"><aqlb v-if="activeName=='second'"/></el-tab-pane>
    </el-tabs>
  </div>
</template>
    
    <script>
import { postAdminCodeGetTagcategory, postAdminCodeDelTag } from "@/api";
import pagination from "@/components/pagination.vue";
import zxbz from "./components/zxbz.vue"
import aqlb from "./components/aqlb.vue"
export default {
  components: { pagination, zxbz, aqlb },
  data() {
    return {
      loading: false,
      dialogVisible: false,
      activeName:"first",
      dataDP: "",
      form: {
        types: 3,
        page: 1,
        size: 10000
      },
      tableData: [],
      total: 1,
    };
  },
  activated() {
    let form = this.form;
    this.postAdminCodeGetTagcategory(form);
  },
  methods: {
    // 新增
    onAdd() {
      this.$router.push({ name: "MaintenanceDetail" });
    },
    // 删除
    onDelete(id) {
      let obj = {
        id,
      };
      this.$confirm("确定删除该面料?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          postAdminCodeDelTag(obj).then((res) => {
            let form = this.form;
            this.postAdminCodeGetTagcategory(form);
            this.$message({
              type: "success",
              message: "删除成功!",
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 编辑
    onEdit(id) {
      this.$router.push({ name: "MaintenanceDetail", query: { id } });
    },
    // 采购列表
    async postAdminCodeGetTagcategory(data) {
      this.loading = true;
      this.form = data;
      postAdminCodeGetTagcategory(data)
        .then((res) => {
          this.loading = false;
          console.log("采购列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.size = 10;
      this.postAdminCodeGetTagcategory(this.form);
    },
  },
};
</script>
    
    <style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
    